home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 09 - 1993 / 09.08 Aug 93 / Icons In Lists / LDEF Example 1.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-06  |  1.6 KB  |  90 lines  |  [TEXT/KAHL]

  1. #include "SetUpA4.h"
  2. Pattern grey={ 170,85,170,85,170,85,170,85 },
  3.     wite={ 0,0,0,0,0,0,0,0 },
  4.     dark={ 119,238,221,187,119,238,221,187 };
  5.  
  6. pascal void main(message,select,r,theCell,offset,len,LH)
  7. int message,offset,len;
  8. ListHandle LH;
  9. Cell theCell;
  10. Boolean select;
  11. Rect *r;
  12. {
  13.     int l;
  14.  
  15.     RememberA0();
  16.     SetUpA4();
  17.     switch(message){
  18.         case 0: break;
  19.         case 1: 
  20.         case 2: doDraw(select,r,offset,LH); break;
  21.         case 3: break;
  22.     }
  23.     RestoreA4();
  24. }
  25.  
  26. doDraw(select,r,offset,LH)
  27. Boolean select;
  28. Rect *r;
  29. int offset;
  30. ListHandle LH;
  31. {
  32.     BitMap icon; 
  33.     Rect src,r1; 
  34.     char p[32],*q,*s,c; 
  35.     register int len,i;
  36.     FontInfo inf;
  37.  
  38.     FillRect(r,grey);
  39.     r->top+=(r->bottom-r->top-32)/2;
  40.     r->left+=(r->right-r->left-32)/2;
  41.     r->bottom=r->top+32;
  42.     r->right=r->left+32;
  43.     InsetRect(r,-4,-4); 
  44.     r1=*r;
  45.     FillRect(r,wite); 
  46.     FrameRect(r); 
  47.     InsetRect(r,3,3);
  48.     FrameRect(r); 
  49.     InsetRect(r,1,1); 
  50.     PenPat(dark);
  51.     for(i=1;i<3;i++){
  52.         MoveTo(r->left-(i+1),r->bottom+i);
  53.         LineTo(r->right+i,r->bottom+i);
  54.         MoveTo(r->right+i,r->top-(i+1));
  55.         LineTo(r->right+i,r->bottom+i); 
  56.     }
  57.     PenNormal();
  58.  
  59.     HLock((**LH).cells);
  60.     icon.baseAddr=(char *)(*(**LH).cells)+offset;
  61.     SetRect(&icon.bounds,0,0,32,32); 
  62.     icon.rowBytes=4;
  63.     src=icon.bounds;
  64.     CopyBits(&icon,&((**LH).port->portBits),&src,r,0,0L);
  65.     offset+=128;
  66.     
  67.     q=(char *)(*(**LH).cells)+offset; 
  68.     s=p;
  69.     len=*s++=*q++;
  70.     while(--len>=0)*s++=*q++; 
  71.     HUnlock((**LH).cells);
  72.     
  73.     if(*p>5){ 
  74.         p[5]=0xC9; 
  75.         *p=5;
  76.     }
  77.     c=(r->left+16)-(StringWidth(p)/2);
  78.     GetFontInfo(&inf); 
  79.     i=r->bottom+inf.ascent+inf.descent+inf.leading; 
  80.     SetRect(&r1,c,r->bottom+4,c+StringWidth(p),i); 
  81.     EraseRect(&r1);
  82.     MoveTo(c,i);
  83.     DrawString(p);
  84.     if(select){
  85.         HiliteMode&=127;
  86.         InvertRect(r);
  87.     }
  88. }
  89.  
  90.